package cn.zkc.library.dao;

import cn.zkc.library.modal.Book;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component(value = "BookDAO" )
public interface BookDAO {

    String table_name = "book" ;
    String insert_field = "name, author, price, number";
    String select_field = "id, name, author, price, number, status";

    @Insert({"insert into", table_name,"(", insert_field, ") values(#{name},#{author},#{price},#{number})"})
    public int addBook(Book book);

    @Select({"select",select_field, "from", table_name})
    public List<Book> selectAll();


}
